package com.neusoft.elmboot.mapper;

import java.util.List;

import com.neusoft.elmboot.po.BusinessVO;

import org.apache.ibatis.annotations.*;
import com.neusoft.elmboot.po.Business;
import org.springframework.stereotype.Repository;

@Repository
public interface BusinessMapper {
	@Select("select * from business where orderTypeId=#{orderTypeId} order by businessId")
	List<Business> listBusinessByOrderTypeId(Integer orderTypeId);




	@Select("select * from business where businessId=#{businessId}")
	Business getBusinessById(Integer businessId);
	
	@Select("select businessName from business where businessId=#{businessId}")
	String getBusinessNameById(Integer businessId);

	@Select("select * from business order by rating desc")
	List<Business> listBusinessOrderByRating();

	@Select("select * from business order by saleVolume desc ")
	List<Business> listBusinessOrderByRatingVolume();


	@Insert("insert into business(businessId,businessName, businessAddress, businessExplain,starPrice," +
			"deliveryPrice," +
			"businessImg) " +
			"values" +
			"(null,#{businessName},#{businessAddress},#{businessExplain},ifnull(#{starPrice},0)," +
			"IFNULL(#{deliveryPrice},0)," +
			"'')")
	Integer addBusiness(BusinessVO business);

	@Update("update business " +
			"set businessName = #{businessName}," +
			"businessExplain = #{businessExplain}," +
			"businessAddress = #{businessAddress}," +
			"starPrice = #{starPrice}," +
			"deliveryPrice=#{deliveryPrice} " +
			"where businessId = #{businessId}")
	Integer update(BusinessVO vo);

	@Delete("delete from business where businessId = #{id}")
	Integer delete(Integer id);

	@Select("select * from business")
	List<Business> list();
}
